<template>
  <div id="OrdersDelivery">
    <g-details
      :detailData="inputData"
      :inputConfig="inputConfig"
      @pop="setData"
    ></g-details>
  </div>
</template>

<script>
import baseMixin from "@/mixins/BaseMixin";

export default {
  mixins: [baseMixin],
  props: {
    inputData: {
      type: Object,
    },
  },
  name: "OrdersDelivery",
  data() {
    return {
      inputConfig: [
        {
          type: "input",
          label: this.$t('out.orderkey'),
          disabled: true,
          props: "orderkey",
        },
        {
          type: "table",
          label: this.$t('out.consigneekey'),
          disabled: false,
          props: "consigneekey",
          tableConfig: [
            {
              label: this.$t('config.shipper'),
              prop: "storerkey",
              input: "input",
            },
            {
              label: this.$t('config.company'),
              prop: "company",
              input: "input",
            },
            {
              label: this.$t('config.city'),
              prop: "city",
              input: "input",
            },
            {
              label: this.$t('config.provice'),
              prop: "state",
              input: "input",
            },
            {
              label: this.$t('config.postcode'),
              prop: "zip",
              input: "input",
            },
            {
              label: this.$t('config.contact'),
              prop: "contact",
              input: "input",
            },
            {
              label: this.$t('config.phone'),
              prop: "phone",
              input: "input",
            },
          ],
          url: `queryStorer/2/?/${this.$store.state.wms}`,
        },
        {
          type: "input",
          label: this.$t('out.b_vat'),
          disabled: false,
          props: "c_vat",
        },
        {
          type: "select",
          label: this.$t('bill.countryCode'),
          disabled: false,
          props: "c_isocntrycode",
          options: this.getOptions("querycodeLkup/ISOCOUNTRY"),
        },
        {
          type: "input",
          label: this.$t('out.c_company'),
          disabled: false,
          props: "c_company",
        },
        {
          type: "input",
          label: this.$t('out.c_address',{no:1}),
          disabled: false,
          props: "c_address1",
        },
        {
          type: "input",
          label: this.$t('out.c_address',{no:2}),
          disabled: false,
          props: "c_address2",
        },
        {
          type: "input",
          label: this.$t('out.c_address',{no:3}),
          disabled: false,
          props: "c_address3",
        },
        {
          type: "input",
          label: this.$t('out.c_address',{no:4}),
          disabled: false,
          props: "c_address4",
        },
        {
          type: "input",
          label: this.$t('out.c_address',{no:5}),
          disabled: false,
          props: "c_address5",
        },
        {
          type: "input",
          label: this.$t('out.c_address',{no:6}),
          disabled: false,
          props: "c_address6",
        },
        {
          type: "input",
          label: this.$t('config.city'),
          disabled: false,
          props: "c_city",
        },
        {
          type: "input",
          label: this.$t('config.provice'),
          disabled: false,
          props: "c_state",
        },
        {
          type: "input",
          label: this.$t('config.postcode'),
          disabled: false,
          props: "c_zip",
        },
        {
          type: "input",
          label: this.$t('config.contact'),
          disabled: false,
          props: "c_contact1",
        },
        {
          type: "input",
          label: this.$t('config.phone'),
          disabled: false,
          props: "c_phone1",
        },
        {
          type: "input",
          label: this.$t('out.fax'),
          disabled: false,
          props: "c_fax1",
        },
        {
          type: "input",
          label: this.$t('app.email'),
          disabled: false,
          props: "c_email1",
        },
        {
          type: "input",
          label: this.$t('out.rtxexpresskey'),
          disabled: false,
          props: "rtxexpresskey",
        },
      ],
    };
  },
  methods: {
    async setData(data, close, listId) {
      this.inputData.consigneekey = data.storerkey;
      try {
        let res = await this.$api.get(`/po/detail/storerkey/${data.storerkey}`);
        
          this.inputData.c_company = res.bean.company;
          this.inputData.c_address1 = res.bean.address1;
          this.inputData.c_address2 = res.bean.address2;
          this.inputData.c_address3 = res.bean.address3;
          this.inputData.c_address4 = res.bean.address4;
          this.inputData.c_address5 = res.bean.address5;
          this.inputData.c_address6 = res.bean.address6;
          this.inputData.c_city = res.bean.city;
          this.inputData.c_state = res.bean.state;
          this.inputData.c_zip = res.bean.zip;
          this.inputData.c_contact1 = res.bean.vat;
          this.inputData.c_phone1 = res.bean.phone1;
          this.inputData.c_fax1 = res.bean.fax1;
          this.inputData.c_email1 = res.bean.email1;
          close(false);
        
      } catch (e) {
        this.$message.error(e);
      }
    },
  },
  mounted() {},
};
</script>

<style scoped></style>
